#include <cstdio>
#include <algorithm>
#include <map>
#include <queue>
#include <vector>
#include <set>
using namespace std;
const int N=2e5+5;
int n,m,d;
int dt[N];
int a[N];
set<pair<int,int>> s;
int main(void){
    scanf("%d%d%d",&n,&m,&d);
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
        s.insert({a[i],i});
    }
    int days=1;
    while(!s.empty()){
        int p=s.begin()->second;
        dt[p]=days;
        s.erase(s.begin());
        while(true){
            auto it =s.lower_bound({a[p]+1+d,0});
            if(it==s.end()){
                break;
            }
            p=it->second;
            s.erase(it);
            dt[p]=days;
        }
        days++;
    }
    printf("%d\n",days-1);
    for(int i=1;i<n;i++){
        printf("%d ",dt[i]);
    }
    printf("%d\n",dt[n]);
    return 0;
}